﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace ProjetoGrupo2
{
    class Credito : SceneBase
    {
        MouseState mouse, oldMouse;
        AnimatedObject bMenu;
        Texture2D creditos;

        public override void start()
        {
            Game1.Self.IsMouseVisible = true;

            
            creditos = (Game1.Self.Content.Load<Texture2D>("Creditos"));

            ProjetoGrupo2.AnimatedObject.AnimationStructure animationMudarCor = new ProjetoGrupo2.AnimatedObject.AnimationStructure();
            animationMudarCor.frameCount = 1;//CONTADOR DE FRAMES
            animationMudarCor.frameWidth = 135; // LARGURA DO SPRITE
            animationMudarCor.frameHeight = 36; // ALTURA DO SPRITE
            animationMudarCor.framePerSecond = 1; // VELOCIDADE DOS QUADROS NA TROCA DE TELA
            animationMudarCor.X = 135;
            animationMudarCor.Y = 0;
            bMenu = new AnimatedObject(Game1.Self.Content.Load<Texture2D>("voltar"), 120, 35);
            bMenu.posicao.X = 500;
            bMenu.posicao.Y = 350;
            bMenu.listaAnimations.Add("mudarCor", animationMudarCor);
        }
        public override void update(GameTime gameTime)
        {
            oldMouse = mouse;
            mouse = Mouse.GetState();
            bMenu.calcularRetangulo();
            bMenu.Update(gameTime);

            if (bMenu.collisionBounds.Contains(mouse.X, mouse.Y))
            {

                bMenu.ChangeAnimation("mudarCor");
            }

            //SENAO NAO EXISTIRA ANIMAÇÃO;
            else
            {

                bMenu.ChangeAnimation("default");
            }
            if (mouse.LeftButton == ButtonState.Pressed && oldMouse != mouse)
            {
                //SE  O botaoPLAY SOFRER COLISÃO DO MOUSE, ELE FARA UMA TROCA DE TELA DE MENU PARA CONTROLES, E EXECUTARÁ UM EFEITO DE SOM.
                if (bMenu.collisionBounds.Contains(mouse.X, mouse.Y))
                {
                    SceneManager.setScene(new Menu());
                    // effect.Play();
                }
            }
        }
        public override void draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(creditos, new Vector2(0, 0), Color.White);
            bMenu.Draw(spriteBatch);
        }

        public override void terminate()
        {
            Game1.Self.IsMouseVisible = false;
            MediaPlayer.Stop();
        }
    }
}
